#ifndef ITEMBUTTON_H
#define ITEMBUTTON_H
#include <QPushButton>
#include <QWidget>
#include <QLabel>
#include <QString>
#include "userinfo.h"
#include "../../models/usermodel.h"

class ItemButton : public QLabel
{
public:
    ItemButton(QWidget *parent = nullptr);
    ~ItemButton();

public:
    void styleSelf();
    void setAvatar(QString avatar);
    void setNickanme(QString nickname);
    void setStatusText(QString statusT);
    void setUid(int u);
    void draw();
    void setRightInfo(UserInfo *info);
    void mousePressEvent(QMouseEvent* event);
    void mouseDoubleClickEvent(QMouseEvent *event);
    void setUserProfile(responseUserInfo profile);
    /**
     * @brief 设置使用的类型，可以设置为chat或者contacts
     * @param type
     */
    void setUseType(int type);
    int getUseType();

    /**
     * @brief 更新红点
     * @param str
     */
    void refreshChatUnreadNum(QString str);

public:
    int defaultHeight = 60;
    UserInfo *rightInfo = nullptr;
    responseUserInfo userProfile;
    //用于contacts
    static const int USE_TYPE_FOR_CONTACTS = 1;
    //用于chat
    static const int USE_TYPE_FOR_CHAT = 2;


private:
    QLabel *avatarLabel = nullptr;
    QLabel *nicknameAndStatusLabel = nullptr;
    QLabel *profileNicknameLabel = nullptr;
    QLabel *profileStatusLabel = nullptr;
    QLabel *unreadLabel = nullptr;
    QString avatar = "";
    QString nickname = "";
    QString statusText = "";
    int uid = 0;
    //未读数
    int unreadNum = 0;
    //用于contacts还是chat还是其他
    int useType = ItemButton::USE_TYPE_FOR_CONTACTS;
};

#endif // ITEMBUTTON_H
